<?php
// +----------------------------------------------------------------------
// | 07FLYSAAS [基于ThinkPHP5.0开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2025-2035 http://www.07fly.xyz
// +----------------------------------------------------------------------
// | Professional because of focus  Persevering because of happiness
// +----------------------------------------------------------------------
// | Author: 开发人生 <goodkfrs@qq.com>
// +----------------------------------------------------------------------

namespace app\plat\logic;

use think\Db;

/**
 * 系统消息逻辑
 */
class TenMsgScan extends PlatBase
{
    /**
     * 把对应的业务提醒扫描出来
     * Author: 开发人生 goodkfrs@qq.com
     * Date: 2021/10/28 0028 15:33
     */
    public function tenMsgScanBus()
    {
        dlog('业务提醒扫描出来=>系统消息中', 'cronjob.txt');
        $fields="name,type,hours,remind_sms,remind_sys,remind_email,remind_weixin,remind_nums,remind_interval";
        $list = $this->modelTenMsgType->getList([], $fields, '', false);
        foreach ($list as $key => $row) {
            switch ($row['type']) {
                //线索跟进
                case 'cst_clue':
                    $this->modelTenMsgType->scanCstClue($row);
                    break;
                //客户跟进
                case 'cst_customer':
                    $this->modelTenMsgType->scanCstCustomer($row);
                    break;
                //商机跟进
                case 'cst_chance':
                    $this->modelTenMsgType->scanCstChance($row);
                    break;
                //销售合同到期
                case 'sal_contract_expire':
                    $this->modelTenMsgType->scanSalContractExpire($row);
                    break;
                //销售订单到期
                case 'sal_order_expire':
                    $this->modelTenMsgType->scanSalOrderExpire($row);
                    break;
                //日程开始提醒
                case 'oa_schedule':
                    $this->modelTenMsgType->scanOaSchedule($row);
                    break;
                //工单提醒
                case 'oa_service':
                    $this->modelTenMsgType->scanOaService($row);
                    break;
                //工单提醒
                case 'workflow_business_history':
                    $this->modelTenMsgType->scanWorkflowBusinessHistory($row);
                    break;
                default :
                    break;
            }
        }
    }
}